package com.ccit.springbootlaw.service.impl;

import com.ccit.springbootlaw.mapper.SubscriptionMapper;
import com.ccit.springbootlaw.pojo.Subscription;
import com.ccit.springbootlaw.service.SubscriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 权益包服务实现类
 * 实现了SubscriptionService接口，提供了权益包相关的业务逻辑
 */
@Service
public class SubscriptionServiceImpl implements SubscriptionService {

    @Autowired
    private SubscriptionMapper subscriptionMapper;

    /**
     * 根据ID查询权益包
     *
     * @param id 权益包ID
     * @return 返回找到的权益包对象，如果未找到则返回null
     */
    @Override
    public Subscription findById(int id) {
        return subscriptionMapper.findById(id);
    }

    /**
     * 根据传入实体进行多条件查询的方法
     *
     * @param subscription 包含查询条件的权益包对象
     * @return 返回符合条件的权益包列表
     */
    @Override
    public List<Subscription> findBySubscriptionWithTypeNameLike(Subscription subscription) {
        return subscriptionMapper.findBySubscriptionWithTypeNameLike(subscription);
    }

    /**
     * 插入新的权益包
     *
     * @param subscription 权益包对象
     * @return 返回插入操作影响的行数
     */
    @Override
    public int insertSubscription(Subscription subscription) {
        return subscriptionMapper.insertSubscription(subscription);
    }

    /**
     * 更新权益包信息
     *
     * @param subscription 包含更新信息的权益包对象
     * @return 返回更新操作影响的行数
     */
    @Override
    public int updateSubscription(Subscription subscription) {
        return subscriptionMapper.updateSubscription(subscription);
    }

    /**
     * 删除权益包
     *
     * @param id 权益包ID
     * @return 返回删除操作影响的行数
     */
    @Override
    public int deleteSubscriptionById(int id) {
        return subscriptionMapper.deleteSubscriptionById(id);
    }

    /**
     * 查询所有权益包
     *
     * @return 返回所有权益包的列表
     */
    @Override
    public List<Subscription> findAllSubscriptions() {
        return subscriptionMapper.findAllSubscriptions();
    }
}